package com.tool.btn;

import com.tool.tcpimg.UIUtils;
import org.come.Frame.ZhuFrame;
import org.come.Jpanel.DepositListJpanel;
import org.come.Jpanel.TestPetJpanel;
import org.come.entity.RoleSummoning;
import org.come.socket.Agreement;
import org.come.socket.SendMessageUntil;
import org.come.until.MessagrFlagUntil;
import org.come.until.UserMessUntil;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;

public class DepositBtn extends MoBanBtn {
    //0上 1下 2顶 3底
    private TestPetJpanel jpanel1;
    private DepositListJpanel jpanel;
    private int p;
    public DepositBtn(String iconpath, int type, int p, DepositListJpanel jpanel) {
        super(iconpath, type);
        // TODO Auto-generated constructor stub
        this.p=p;
        this.jpanel=jpanel;


    }

    public DepositBtn(String iconpath, int type, int p, String text, DepositListJpanel jpanel) {
        // TODO Auto-generated constructor stub
        super(iconpath, type, UIUtils.COLOR_BTNTEXT);
        this.setText(text);
        this.setFont(UIUtils.TEXT_FONT);
        setVerticalTextPosition(SwingConstants.CENTER);
        setHorizontalTextPosition(SwingConstants.CENTER);
        this.p=p;
        this.jpanel = jpanel;
    }

    public DepositBtn(String iconpath, int type,Color[] colors,
                      Font font,String text,Integer typeBtn, DepositListJpanel jpanel) {
        // TODO Auto-generated constructor stub
        super(iconpath, type, colors);
        this.setText(text);
        this.setFont(UIUtils.TEXT_FONT);
        setVerticalTextPosition(SwingConstants.CENTER);
        setHorizontalTextPosition(SwingConstants.CENTER);
        this.p=p;
        this.jpanel = jpanel;
    }


    @Override
    public void chooseyes() {
        // TODO Auto-generated method stub

    }

    @Override
    public void chooseno() {
        // TODO Auto-generated method stub

    }

    @Override
    public void nochoose(MouseEvent e) {
        // TODO Auto-generated method stub
        //获取当前选中的位置
        int w=jpanel.getListpet().getSelectedIndex();
        if (w==-1) {
            return;
        }
        RoleSummoning roleSummoning = UserMessUntil.getDepositPetListTable().get(w);
        if(roleSummoning == null){
            ZhuFrame.getZhuJpanel().addPrompt("要取出的召唤兽不存在！");
            return;
        }
        String mes = Agreement.getAgreement().petDepositAction("retrieve=" + roleSummoning.getSid());
        // 向服务器发送信息
        SendMessageUntil.toServer(mes);
//        RoleData data=RoleData.getRoleData();
//        List<String> list=null;
//        //0上 1下 2顶 3底
//        if (p==0) {
//            list=data.CHelpBb(w, w-1);
//        }else if (p==1) {
//            list=data.CHelpBb(w, w+1);
//        }else if (p==2) {
//            list=data.CHelpBb(w, 0);
//        }else {
//            list=data.CHelpBb(w, 99);
//        }
//        if (list!=null) {
//            jpanel.init(list);
//        }

    }

}
